package com.xfgg.cloud.adapter;

import com.xfgg.cloud.adapter.request.GameRequest;
import com.xfgg.cloud.adapter.request.GameSearchRequest;
import com.xfgg.cloud.adapter.request.LoginRequest;
import com.xfgg.cloud.app.ElasticSearchService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能介绍
 * 1、需要将出入参的DTO和业务层的VO/DO对象进行转换
 * 2、不包含任何的业务逻辑，只包含参数转换和业务无关的校验逻辑
 * 3、接口返回值缓存类的逻辑，可以放在这个模块中实现，因为这个动作不包含业务逻辑
 *
 * @author xfgg
 */
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class BaseController {
    private final ElasticSearchService elasticSearchService;

    @GetMapping("/es/{term}")
    public List<LoginRequest> getLoginLog(@PathVariable String term) {
        return elasticSearchService.getLoginLogByTerm(term);
    }

    @PostMapping("/game/search")
    public Map<String, Object> gameSearch(@RequestBody GameSearchRequest gameSearchRequest) {
        return new HashMap<>();
    }

    @PostMapping("/game")
    public ResponseEntity<Void> putGame(@RequestBody GameRequest gameRequest) {
        return new ResponseEntity<>(HttpStatus.OK);
    }

}
